package com.drcoffee.drcoffeemall.mapper;

import com.drcoffee.drcoffeemall.entry.*;
import com.drcoffee.drcoffeemall.entry.ocm.OrderDetail4OCM;
import com.drcoffee.drcoffeemall.entry.ocm.OrderHeader4OCM;
import com.drcoffee.drcoffeemall.entry.ocm.PartInOCM;
import com.drcoffee.drcoffeemall.entry.ocm.PriceInOCM;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
@Repository
public interface OrderMapper {
    List<Object> getNot();

    List<Map<String, Object>> getOrderParts(Map<String, Object> paramMap);

    @Update("UPDATE t_order SET status=#{status},${statusDate}=CURRENT_TIMESTAMP WHERE code = #{code}")
    void setOrderStatus(String code, Integer status, String statusDate);

    @Update("UPDATE t_order SET flip_status = 'Y',ocm_code = #{code},re_code_flag = 'T' WHERE code = #{code}")
    void setFlipStatus(String code);

    List<Map<String, Object>> getTransportOrder(Map<String, Object> paramMap);

    @Update("UPDATE t_order SET transport_code = #{transport_code},status = '3', status_time_03 = CURRENT_TIMESTAMP WHERE code = #{order_code}")
    void setTransportCode(String order_code, String transport_code);

    @Select("SELECT a.*, CONCAT(c.o_file_path, c.folder, a.proof_path) as file_path,b.firm_name " +
            "FROM t_pay_voucher a LEFT JOIN t_order b ON a.order_code = b.code,t_file_path c " +
            "WHERE a.is_sh = 'N' AND c.bsh_one = 'J' AND c.bsh_two = 1")
    List<PayVoucher> getVoucherByNo();

    @Update("UPDATE t_pay_voucher SET is_sh = #{is_sh},review = #{review} WHERE order_code = #{order_code}")
    void setVoucherY(PayVoucher voucher);

    @Update("UPDATE t_order SET back_status = #{back_status} WHERE code = #{order_code}")
    void setOrderBackStatus(String order_code, int back_status);

    @Select("SELECT * FROM t_order WHERE code = #{orderCode}")
    Map<String, Object> getOrderByCode(String orderCode);

    @Update("UPDATE t_order SET invoice_status = #{invoice_status} WHERE code = #{order_code} ")
    void setInvoiceStatus(String order_code, Integer invoice_status);

    List<Map<String, Object>> getAllTrade(Map<String, Object> paramMap);

    Integer getAllTradeCount(Date date1,Date date2);

    //    @Update("UPDATE t_trade SET erp_order_code = #{erp_order_code} WHERE order_code = #{order_code} ")
//    void UpdateErpCodeByOrderCode(List<String> erp_order_code, List<String> order_code);

//    @Select("SELECT KC47.oea_file.OEA01 FROM KC47.oea_file WHERE oea12 LIKE #{search}")
//    List<String> getErpCode(List<String> search);


    List<Map<String, Object>> getNotThrowOrdderHead(Map<String, Object> paramMap);

    List<Map<String, Object>> getNotThrowOrdderDetail(Map<String, Object> paramMap);

    Integer setOrderDisplace(Map<String, Object> paramMap);

    Integer setOrderDisplace1(Map<String, Object> paramMap);

    String getOcmOrderMaxCode();

    void addOrderHeader(OrderHeader4OCM orderHeader4OCM);

    PartInOCM getPartInfo(String part_code);

    String getUserChannel(String account);

    void addOrderDetail(OrderDetail4OCM orderDetail4OCM);

    List<Map<String, Object>> getOrder(Map<String, Object> paramMap);

    List<String> getOrderOcmCodeByRCodeFlagIsT();

    void setOrderOcmCode(String erp_order_code, String ocm_code);

    Map<String, Object> getOrderByToCode(String code);

    List<Map<String, Object>> getOrderPartList(String code);

    List<Map<String, Object>> getVoucherData(Map<String, Object> paramMap);

    void verifyReceiveGoods();

}
